﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace UIPrototyper
{
    public class ControlList<T> : List<T>, ISelectable where T : ISelectable
    {
        #region IChanged Members

        public event ChangedHandler iChanged;

        public void LaunchChangedEvent(IChanged pChangedObject)
        {
            if (iChanged != null)
            {
                iChanged(pChangedObject);
            }
        }

        #endregion

        #region ICopy Members

        public ISelectable Copy()
        {
            ControlList<T> myCopy = new ControlList<T>();

            foreach (T t in this)
            {
                if (t.GetType() != typeof(SelectionUC))
                {
                    myCopy.Add((T)t.Copy());
                }
            }

            return myCopy;
        }

        #endregion

        public new void Add(T t)
        {
            base.Add(t);

            t.iChanged += new ChangedHandler(t_iChanged);

            LaunchChangedEvent(this);
        }

        public new void Remove(T t)
        {
            base.Remove(t);

            LaunchChangedEvent(this);
        }

        void t_iChanged(IChanged changedObject)
        {
            LaunchChangedEvent(changedObject);
        }

        #region ISelectable Members

        public string Description
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public Property Properties
        {
            get { throw new NotImplementedException(); }
        }

        #endregion
    }
}
